{template 'public/header'}
{template 'public/comhead'}
<link rel="stylesheet" type="text/css" href="../addons/zh_gjw/template/public/ygcsslist.css">
<style type="text/css">
    .yg5_key>div{float: left;line-height: 34px;}
    .store_td1{height: 45px;}
    .store_list_img{width: 60px;height: 60px;}
    .yg5_tabel{border-color: #e5e5e5;outline: 1px solid #e5e5e5;}
    .yg5_tr2>td{padding: 10px 15px;border: 1px solid #e5e5e5;text-align:center;}
    .yg5_tr1>th{
        border: 1px solid #e5e5e5;
        padding-left: 15px;
        background-color: #FAFAFA;
        font-weight: bold;
        text-align: center;
    }
    .yg5_btn{background-color: #EEEEEE;color: #333;border: 1px solid #E4E4E4;border-radius: 6px;width: 100px;height: 34px;}
    .hourselect{width:80px !important;}
    .minuteselect{width:80px !important;}

    .hhd{padding:10px !important;}
    .hhd input{height:26px;float:left;}
    .hhd span{float:left;line-height:25px;}
    .tabt{width:100%;height:30px;}
    .tabt div{float:left;width:50%;text-align:center;height:30px;line-height:30px;cursor:pointer;}
    .tabactive{background-color:#ccc;color:#428bca;font-weight:700;}
    /*#frame-2{display: block;visibility: visible;}*/
</style>
<ul class="nav nav-tabs">
    <li   {if $active==0} class="active" {/if}><a href="{php echo $this->createWebUrl2('cusorder')}">全部列表</a></li>
    <li   {if $active==1} class="active" {/if}><a href="{php echo $this->createWebUrl2('cusorder',array('type'=>1))}">抖宝订单</a></li>
    <li   {if $active==2} class="active" {/if}><a href="{php echo $this->createWebUrl2('cusorder',array('type'=>2));}">微拍订单</a></li>
    <li   {if $active==3} class="active" {/if}><a href="{php echo $this->createWebUrl2('cusorder',array('type'=>3));}">地摊订单</a></li>
    <li   {if $active==4} class="active" {/if}><a href="{php echo $this->createWebUrl2('cusorder',array('type'=>4));}">定制订单</a></li>

</ul>
<ul class="nav nav-tabs">
    <li   {if $activef==1} class="active" {/if}><a href="{php echo $this->createWebUrl2('cusorder',array('type'=>$active,'state'=>1));}">待付款</a></li>
    <li   {if $activef==2} class="active" {/if}><a href="{php echo $this->createWebUrl2('cusorder',array('type'=>$active,'state'=>2));}">待发货</a></li>
    <li   {if $activef==3} class="active" {/if}><a href="{php echo $this->createWebUrl2('cusorder',array('type'=>$active,'state'=>3));}">待收货</a></li>
    <li   {if $activef==4} class="active" {/if}><a href="{php echo $this->createWebUrl2('cusorder',array('type'=>$active,'state'=>4));}">已完成</a></li>
    <!-- <li   {if $activef==5} class="active" {/if}><a href="{php echo $this->createWebUrl2('cusorder',array('type'=>$active,'state'=>5));}">售后</a></li> -->

</ul>

  

<div class="main">
        <div class="panel panel-default">
            <div class="panel-body">
                
                <form action="" method="get" class="col-md-4">
                    <input type="hidden" name="c" value="site" />
                    <input type="hidden" name="a" value="entry" />
                    <input type="hidden" name="m" value="zh_gjw" />
                    <input type="hidden" name="do" value="cusorder" />
                    <div class="input-group" style="width: 300px">
                        <input type="text" name="keywords" class="form-control" placeholder="请输入订单号\姓名\手机号">
                        <span class="input-group-btn">
                    <input type="submit" class="btn btn-default" style="padding: 7.5px 12px" name="submit" value="查找"/>
                </span>
                    </div>
                    <input type="hidden" name="token" value="{$_W['token']}"/>
                </form>
                <form action="" method="get" class="col-md-4">
                    <input type="hidden" name="c" value="site" />
                    <input type="hidden" name="a" value="entry" />
                    <input type="hidden" name="m" value="zh_gjw" />
                    <input type="hidden" name="do" value="cusorder" />
                    <div class="col-md-4">
              
                        <div class="input-group" style="width: 100px">
                            {php echo tpl_form_field_daterange('time',array('start' =>$_GPC['time']['start'], 'end' => $_GPC['time']['end']),true);}
                            <span class="input-group-btn">
                                <input type="submit" class="btn btn-default" name="submit" value="查找"/>
                            </span>
                        </div>
                    </div>
                    <input type="hidden" name="token" value="{$_W['token']}"/>
                </form>
            </div>
        </div>

    <div class="panel panel-default">
        <div class="panel-heading">
            <button type="button" id="allselect"><i>批量删除</i></button>
        </div>
        <div class="panel-body" style="padding: 0px 15px;">
            <div class="row">
                <table class="yg5_tabel col-md-12">

                    <tr class="yg5_tr1">
                        <th class="store_td1 col-md-1">
                            <input type="checkbox" class="allcheck" />
                            <span class="store_inp">全选</span>
                        </th>
                        <th>ID号</th>
                        <th>订单号</th>
                        <!-- <th>留言</th> -->
                        <th>姓名</th>
                        <th>手机号</th>
                        <th>时间</th>
                        <th>操作</th>

                    </tr>
                    {loop $orders $item}
              <tr class="yg5_tr2">
                 <td>
                    <input type="checkbox" name="test" value="{$item['id']}">
                    <input type="hidden" name="uniacid" class="uniacid" value="{$item['uniacid']}">
                 </td>
                  <td>
                      {$item['id']}
                  </td>
                  <td>
                      {$item['ordernum']}
                  </td>
                  <!-- <td>
                      {$item['message']}
                  </td> -->
                  <td >
                      {$item['uname']}
                  </td>
                  <td>
                      {$item['phone']}
                  </td>
                  <td >
                      {$item['time']}
                  </td>
                  <td>
                      {if $item['state']==1}
                          <span style="cursor:pointer;" class="label label-warning">待付款</span>
                      {elseif $item['state']==2}
                          <!-- <a style="cursor:pointer;" class="label label-primary">待发货</a> -->
                          <!-- <a href="{php echo $this->createWebUrl2('cusorder', array('op' => 'three', 'id' => $item['id']))}" style="cursor:pointer;" class="label label-primary">确认发货</a> -->
                          <a href="javascript:void(0);" data-toggle="modal" data-target="#myModalb{$item['id']}" class="label label-primary">确认发货 </a>
                      {elseif $item['state']==3}
                          <span id="time{$item['id']}">剩余时间n天nn时nn分nn秒</span><a href="{php echo $this->createWebUrl2('cusorder', array('op' => 'four', 'id' => $item['id']))}" style="cursor:pointer;" class="label label-danger">确认收货<input type="hidden" name="time" class="hide_time" value="{$item['id']}"></a>
                      {elseif $item['state']==4}
                          <span style="cursor:pointer;" class="label label-success"> 已完成</span>
                      {/if}
                      <a href="{php echo $this->createWebUrl2('corderdetail',array('id'=>$item['id']));}" class="storespan btn btn-xs">
                          <span class="fa">详情页</span>
                          <span class="bianji">查看订单详情
                            <span class="arrowdown"></span>
                          </span>

                      </a>
                      <a href="javascript:void(0);" class="storespan btn btn-xs" data-toggle="modal" data-target="#myModal{$item['id']}">
                          <span class="fa fa-trash-o"></span>
                          <span class="bianji">删除<span class="arrowdown"></span>
                                </span>
                      </a>
                  </td>

              </tr>
                    <div class="modal fade" id="myModal{$item['id']}" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
                        <div class="modal-dialog" role="document">
                            <div class="modal-content">
                                <div class="modal-header">
                                    <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                                    <h4 class="modal-title" id="myModalLabel" style="font-size: 20px;">提示</h4>
                                </div>
                                <div class="modal-body" style="font-size: 20px">
                                    确定删除么？
                                </div>
                                <div class="modal-footer">
                                    <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                                    <a href="{php echo $this->createWebUrl2('cusorder', array('op' => 'delete', 'id' => $item['id']))}" type="button" class="btn btn-info" >确定</a>
                                </div>
                            </div>
                        </div>
                    </div>
                    
                    <div class="modal fade" id="myModalb{$item['id']}" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
                      <div class="modal-dialog" role="document" style="min-width: 300px!important;width: 250px;">
                          <form action="" method="post" enctype="multipart/form-data">
                              <div class="modal-content">
                                  <div class="modal-header">
                                      <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                                      <h4 class="modal-title" id="myModalLabel" style="font-size: 20px;">快递物流</h4>
                                  </div>
                                  <div class="tabt">
                                    <div class="cur1">快递</div>
                                    <div class="cur2">物流</div>
                                  </div>
                                  <div class="modal-body hhd kd" style="font-size:12px">
                                      <span>快递公司：</span><input type="text" name="excompany" class="accout_inp col-md-9" placeholder="请输入快递公司">
                                  </div>
                                  <div class="modal-body hhd kd" style="font-size:12px">
                                      <span>快递单号：</span><input type="text" name="exordernum" class="accout_inp col-md-9" placeholder="请输入快递单号">
                                  </div>
                                  <div class="modal-body hhd wl" style="font-size:12px">
                                      <span>物流公司：</span><input type="text" name="excompanys" class="accout_inp col-md-9" placeholder="请输入物流公司">
                                  </div>
                                  <div class="modal-body hhd wl" style="font-size:12px">
                                      <span>物流单号：</span><input type="text" name="exordernums" class="accout_inp col-md-9" placeholder="请输入物流单号">
                                  </div>
                                  <div class="modal-footer">
                                      <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                                      <input type="submit" name="submit2" class="btn btn-info" value="确定">
                                      <input type="hidden" name="token" value="{$_W['token']}"/>
                                      <input type="hidden" name="id" value="{$item['id']}"/>
                                  </div>
                              </div>
                          </form>
                      </div>
                    </div>
                  {/loop}

                {if empty($list)}
               <tr class="yg5_tr2">
                  <td colspan="10">
                    暂无订单信息
                  </td>
                </tr>

              {/if}

                </table>
            </div>
        </form>
    </div>
    {$pager}
</div>
</div>
<script type="text/javascript">
  var uniacid;
  uniacid=$("input[name='uniacid']").val();
	window.setInterval(function(){ // 每秒从服务器取一次数据
		var ids = new Array(); 
		
		for (var i =0; i < $(".hide_time").length; i++) {
			var num=$(".hide_time").eq(i).val();
			ids.push(num);
		}
		$.ajax({
	        type:"get",
	        url:"{$_W['siteroot']}/app/index.php?i="+uniacid+"&c=entry&do=time&m=zh_gjw",
	        dataType:"json",
	        data:{ids:ids},
	        success:function(res){
	        	if(res.code==200) {
		        	for (var j =0;j < res.goid.length;j++) {
		        		document.getElementById("time"+res.goid[j]).innerHTML='剩余时间'+res.reday[j]+'天'+res.rehours[j]+'时'+res.reminute[j]+'分'+res.resecond[j]+'秒';
		        	}
		        }else if(res.code==201){
		        	window.location.reload();
		        }
	        }
	    })
	},1000);
    $(function(){
        // $("#frame-12").addClass("in");
        // $("#frame-12").show();
        $("#frame-2").show();
        $("#yframe-2").addClass("wyactive");
        // ———————————————批量删除———————————————
        $("#allselect").on('click',function(){
            var check = $("input[type=checkbox][class!=allcheck]:checked");
            if(check.length < 1){
                alert('请选择要删除的订单!');
                return false;
            }else if(confirm("确认要删除此订单?")){
                var ids = new Array();
                check.each(function(i){
                    ids[i] = $(this).val();
                });
               // console.log(ids);return false;
                $.ajax({
                    type:"post",
                    url:"{$_W['siteroot']}/app/index.php?i="+uniacid+"&c=entry&do=Deleteorderlist&m=zh_gjw",
                    dataType:"text",
                    data:{id:ids},
                    success:function(data){
                        console.log(data);
                        // return false;
                        location.reload();
                    }
                })

            }
        });
        $(".allcheck").on('click',function(){
            var checked = $(this).get(0).checked;
            $("input[type=checkbox]").prop("checked",checked);
        });

    })
    $(".cur1").addClass("tabactive");
    $(".wl").hide();
    $(".cur1").on('click',function(){
      $(this).addClass("tabactive");
      $(this).siblings().removeClass("tabactive");
      $(".kd").show();
      $(".wl").hide();
    })
    $(".cur2").on('click',function(){
      $(this).addClass("tabactive");
      $(this).siblings().removeClass("tabactive");
      $(".kd").hide();
      $(".wl").show();
    })
</script>